﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SLSYJ.Core.DataInterfaces;
using SLSYJ.Core;
using NHibernate;
using ProjectBase.Data.NHibernate;
using NHibernate.Criterion;

namespace SLSYJ.Data
{
    public class EmployeeDao : GenericDao<Employee>, IEmployeeDao
    {
        #region IEmployeeDao Members

        public List<Employee> LoadEmployeeBy(string employeeCategoryName)
        {
            ICriteria criteria = Session.CreateCriteria(typeof(Employee))
                .Add(Expression.Eq("Name", employeeCategoryName));

            return criteria.List<Employee>() as List<Employee>;
        }


        public List<Employee> LoadAllMatching(string filter)
        {
            ICriteria criteria = Session.CreateCriteria(typeof(Employee))
            .Add(Expression.Or(Expression.InsensitiveLike("Name", filter, MatchMode.Anywhere),
                 Expression.InsensitiveLike("Surname", filter, MatchMode.Anywhere)));

            return criteria.List<Employee>()
                as List<Employee>;
        }

        #endregion
    }
}